﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Rename
{
    public partial class Form8 : Form
    {
        public Form8()
        {
            InitializeComponent();
            Text = "动态改变ListView标题高度示例";
            Size = new Size(600, 400);
            var listView = new DynamicHeaderListView
            {
                Dock = DockStyle.Fill
            };

            // 添加列（第一列文本较长时会触发高标题）
            listView.Columns.Add("短标题", 100);
            listView.Columns.Add("这是一个很长的标题文本会触发高标题显示", 200);
            listView.Columns.Add("普通标题", 150);

            // 添加测试数据
            listView.Items.Add(new ListViewItem(new[] { "数据1", "内容1", "备注1" }));
            listView.Items.Add(new ListViewItem(new[] { "数据2", "内容2", "备注2" }));

            // 添加切换按钮
            var toggleBtn = new Button
            {
                Text = "切换标题高度",
                Dock = DockStyle.Top
            };
            toggleBtn.Click += (s, e) => listView.ToggleHeaderHeight();

            Controls.Add(listView);
            Controls.Add(toggleBtn);
        }
    }
}
